package com.itheima.practice;
//编写工具类，在工具类中编写拷贝方法，传入目标文件路径和源文件路径，无返回值。
import java.io.*;

public final class CopyApi {
    public static final void copy(File file1,File file2) throws IOException {
        //1.使用缓冲流对象
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file1));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file2));
        //2.拷贝
        int len;
        byte[] data = new byte[1024];
        while ((len = bis.read(data)) != -1){
            bos.write(data);
        }
        //3.释放资源
        bis.close();
        bos.close();
    }
}
